import { defineStore } from "pinia";

import { getBottomInfo } from "@/api/home";
import { AudioUtils } from "@/utils/audioUtils";

interface BasicStore {
  bottomInfo: API.Home.BottomInfoResult;
  cardToggle: boolean;
  depositToggle: boolean;
  withdrawToggle: boolean;
  addressToggle: boolean;
  audio: AudioUtils;
}

export const useBasic = defineStore("basic", {
  state: (): BasicStore => ({
    bottomInfo: {},
    cardToggle: false,
    depositToggle: false,
    withdrawToggle: false,
    addressToggle: false,
    audio: new AudioUtils(),
  }),
  actions: {
    async getBottomInfo() {
      if (Object.keys(this.bottomInfo).length === 0) {
        this.bottomInfo = await getBottomInfo();
      }
    },
  },
});
